package ds;

public class MyStack<T> {
    private static class Node<T> {
        T value;
        Node<T> next;
        Node(T value) { this.value = value; }
    }
    private Node<T> top;
    public void push(T value) {
        Node<T> node = new Node<>(value);
        node.next = top;
        top = node;
    }
    public T pop() {
        if (top == null) return null;
        T val = top.value;
        top = top.next;
        return val;
    }
    public boolean isEmpty() { return top == null; }
} 